package com.stars.controller.sys;

import com.stars.common.annotation.UserMenuUpdateRedis;
import com.stars.common.base.ResultMsg;
import com.stars.controller.advice.CommonExceptionHandler;
import com.stars.services.system.PermissionRelationAccessService;
import com.stars.services.system.PermissionRelationConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : alex
 * @version ：1.0.0
 * @Date : create by 2017/12/5 18:13
 * @description ：资源和角色操作控制层
 * @note 注意事项
 */
@RestController
@RequestMapping("/permissionRelation")
@Api(tags = "资源和角色操作控制层")
public class PermissionRelationController extends CommonExceptionHandler {

    @Autowired()
    private PermissionRelationConfigService permissionRelationConfigServiceImpl;
    @Autowired
    private PermissionRelationAccessService permissionRelationAccessServiceImpl;

   /**
    * 添加资源和角色之间的关系
    * @param ids
    * @param roleId
    * @return
    * @throws Exception
    */
   @PostMapping(value = "/add")
   @ApiOperation(value = "添加资源和角色之间的关系")
   @UserMenuUpdateRedis(permission = true)
   public ResultMsg permissionRelationInsert(String ids,String roleId) throws Exception{

       return permissionRelationConfigServiceImpl.permissionRelationInsert(ids,roleId);
   }


    /**
     * 修改用户和角色关系
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/delById")
    @ApiOperation(value = "修改用户和角色关系")
    @UserMenuUpdateRedis(permission = true)
    public ResultMsg updateRelation(String ids,String roleId) throws Exception{
        return permissionRelationConfigServiceImpl.updateEntity(ids,roleId);
    }




}
